<template>
	<div class="app-container">
		<el-form :inline="true" :model="dataForm" @submit.native.prevent @keyup.enter.native="getDataList()">
			<el-form-item>
				<el-input placeholder="请输入内部检验依据搜索" v-model="dataForm.accordingToInside" :clearable="true" size="mini">
					<template slot="prepend">内部检验依据</template>
				</el-input>
			</el-form-item>

			<el-form-item>
				<el-input placeholder="请输入内部标准号搜索" v-model="dataForm.insideInspectionStandardNum" :clearable="true"
					size="mini">
					<template slot="prepend">内部标准号</template>
				</el-input>
			</el-form-item>

			<el-form-item>
				<el-input placeholder="请输入国家标准号搜索" v-model="dataForm.nationInspectionStandardNum" :clearable="true"
					size="mini">
					<template slot="prepend">国家标准号</template>
				</el-input>
			</el-form-item>

			<el-form-item>
				<el-button @click="searchData()" type="primary" class="pan-btn primary-btn" size="mini"
					icon="el-icon-search">搜索</el-button>
			</el-form-item>

			<el-form-item>
				<el-button v-if="isAuth('base:standard:save') && isNoSelect" @click="addModule()" type="success"
					class="pan-btn success-btn" size="mini" icon="el-icon-upload">新增</el-button>
			</el-form-item>

			<el-form-item>
				<el-button v-if="isAuth('base:standard:delete') && isNoSelect" @click="deleteData()" type="danger"
					class="pan-btn danger-btn" size="mini" icon="el-icon-delete">删除</el-button>
			</el-form-item>
		</el-form>

		<el-table :data="dataList" v-loading="dataListLoading" border fit highlight-current-row
			@selection-change="selectionChange" @row-click="rowClickHandle" style="width: 100%">
			<el-table-column type="selection" header-align="center" align="center" width="50">
			</el-table-column>
			<el-table-column type="expand">
				<template slot-scope="props">
					<el-card>
						<el-collapse>
							<el-collapse-item v-for="item in props.row.items"
								:title="'【' + item.inspectionCategoryName + '】' + ' -> ' + item.inspectionItemName + ' -> ' + item.inspectionGroupName"
								:key="item.inspectionItemId">
								<el-row>
									<el-col :span="8">检验项目编号:</el-col>
									<el-col :span="16">{{item.inspectionItemId}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">父级项目编号:</el-col>
									<el-col :span="16">{{item.parentId}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">是否用于打印报告:</el-col>
									<el-col :span="16">{{item.isPrint == 0 ? '是' : '否'}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">打印别名:</el-col>
									<el-col :span="16">{{item.printItemName}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">所属检验组:</el-col>
									<el-col :span="16">{{item.inspectionGroupName}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">水检验类别:</el-col>
									<el-col :span="16">{{item.waterQuantityName}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">国家标准值:</el-col>
									<el-col :span="16"><span v-html="item.nationInspectionItemValue"></span></el-col>
								</el-row>
								<el-row>
									<el-col :span="8">内部标准值:</el-col>
									<el-col :span="16"><span v-html="item.insideInspectionItemValue"></span></el-col>
								</el-row>
								<el-row>
									<el-col :span="8">打印时标准规定显示为原本标准还是应符合规定:</el-col>
									<el-col :span="16">{{item.printValue == 0 ? '原本标准' : '应符合规定。'}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">标准值是否包含化学式:</el-col>
									<el-col :span="16">{{item.haveFormulaValue == 0 ? '是' : '否'}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">检验结果是否为数值:</el-col>
									<el-col :span="16">{{item.isNumber == 0 ? '是' : '否'}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">是否为每半年检一次:</el-col>
									<el-col :span="16">{{item.isHalfYearTest == 0 ? '是' : '否'}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">打印时检验结果显示为原本结果还是系统内置结果(符合/不符合规定):</el-col>
									<el-col :span="16">{{item.printConfig == 0 ? '原本结果' : '系统内置'}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">标准工时1(h):</el-col>
									<el-col :span="16">{{item.manHourOne}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">标准工时2(h):</el-col>
									<el-col :span="16">{{item.manHourTwo}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">内部标准值下限:</el-col>
									<el-col :span="16">{{item.insideInspectionItemDownValue}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">内部标准值上限:</el-col>
									<el-col :span="16">{{item.insideInspectionItemUpValue}}</el-col>
								</el-row>
								<el-row>
									<el-col :span="8">内部标准值单位:</el-col>
									<el-col :span="16">{{item.insideInspectionItemValueUnit}}</el-col>
								</el-row>
							</el-collapse-item>
						</el-collapse>
					</el-card>
				</template>
			</el-table-column>
			<el-table-column prop="insideInspectionStandardId" header-align="center" align="center" label="标准编号"
				width="100">
			</el-table-column>
			<el-table-column prop="accordingToInside" header-align="center" align="center" label="内部检验依据">
			</el-table-column>
			<el-table-column prop="productGmpLike" header-align="center" align="center" label="物料编码关键字">
			</el-table-column>
			<el-table-column header-align="center" align="center" label="国家标准号">
				<template slot-scope="{row}">
					<span v-html="row.nationInspectionStandardNum"></span>
				</template>
			</el-table-column>
			<el-table-column prop="insideInspectionStandardNum" header-align="center" align="center" label="内部标准号"
				width="150">
			</el-table-column>
			<el-table-column prop="parentNum" header-align="center" align="center" label="父级标准号" width="150">
				<template slot-scope="scope">
					<el-link type="primary" @click="goParent(scope.row.parentNum)">{{scope.row.parentNum}}</el-link>
				</template>
			</el-table-column>
			<el-table-column header-align="center" align="center" label="生效日期" width="100">
				<template slot-scope="{row}">
					{{ row.takeEffectTime | changeTime }}
				</template>
			</el-table-column>
			<el-table-column header-align="center" align="center" label="生效批号" width="100">
				<template slot-scope="{row}">
					{{ row.effectiveBatchNum }}
				</template>
			</el-table-column>
			<el-table-column header-align="center" align="center" label="已生效" width="100">
				<template slot-scope="{row}">
					<el-switch v-model="row.isWaitTakeEffect" disabled active-color="#13ce66" inactive-color="#ff4949"
						:active-value="1" :inactive-value="0">
					</el-switch>
				</template>
			</el-table-column>
			<el-table-column prop="usable" header-align="center" align="center" label="是否可用" width="100">
				<template slot-scope="scope">
					<el-switch v-model="scope.row.usable" disabled active-color="#13ce66" inactive-color="#ff4949"
						:active-value="0" :inactive-value="1">
					</el-switch>
				</template>
			</el-table-column>
			<el-table-column v-if="isNoSelect" header-align="center" align="center" label="操作" width="400">
				<template slot-scope="scope">
					<el-button
						v-if="isAuth('base:standard:collocate') && scope.row.usable == 0 && scope.row.isWaitTakeEffect != 0"
						type="text" size="small" @click="collocate(scope.row)">配置</el-button>
					<el-button
						v-if="isAuth('base:standard:upgrade') && scope.row.usable == 0 && scope.row.isWaitTakeEffect == 0"
						type="text" size="small" @click="nowTake(scope.row)">立即生效</el-button>
					<el-button v-if="isAuth('base:standard:update')" type="text" size="small"
						@click="updateData(scope.row)">修改</el-button>
					<el-button v-if="isAuth('base:standard:delete')" type="text" size="small"
						@click="deleteData(scope.row.insideInspectionStandardId)">删除</el-button>
					<el-button
						v-if="isAuth('base:standard:upgrade') && scope.row.usable == 0 && scope.row.isWaitTakeEffect != 0"
						type="text" size="small" @click="upgrade(scope.row)">升级</el-button>
					<el-button v-if="isAuth('base:standard:sort')" type="text" size="small" @click="sort(scope.row)">排序
					</el-button>
					<el-button v-if="isAuth('base:standard:sync') && scope.row.isWaitTakeEffect != 0" type="text"
						size="small" @click="sync(scope.row)">同步</el-button>
					<el-button v-if="isAuth('base:standard:preview')" type="text" size="small"
						@click="preview(scope.row)">预览报告</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
			:page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
			layout="total, sizes, prev, pager, next, jumper"></el-pagination>

		<el-dialog title="同步" :visible.sync="syncVisible" :before-close="closeSync" :close-on-click-modal="false"
			width="80%">
			<el-form label-position="top">
				<el-form-item v-if="syncContent == 'wk'"
					label="请选择分样日期，">
					<el-date-picker v-model="startTime" align="right" type="date" placeholder="分样日期"
						style="width: 100%;" format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd HH:mm:ss">
					</el-date-picker>
				</el-form-item>
				<template v-else>
					<el-form-item label="请选择请验日期后点搜索按钮将列出该时间点及以后所有的请验单,您可以针对性的同步标准检验项数据.">
						<el-date-picker v-model="startTime" align="right" type="date" placeholder="分样日期"
							style="width: 20%;" format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd HH:mm:ss">
						</el-date-picker>
            <el-button icon="el-icon-search" class="pan-btn primary-btn" @click="queryCheckList()"></el-button>
					</el-form-item>
					<el-form-item label="同步方式">
						<el-radio v-model="syncWay" label="0">仅同步当前标准</el-radio>
						<el-radio v-model="syncWay" label="1">将此标准的上一个旧标准更新为当前标准(新标准)</el-radio>
					</el-form-item>
				</template>
			</el-form>



      <!-- 请验单列表 -->
      <el-table
            ref="multipleTable"
            :data="tableData"
            tooltip-effect="dark"
            :loading="checkListLoading"
            @selection-change="handleSelectionChange"
            style="width: 100%">
            <el-table-column
              type="selection"
              width="55">
            </el-table-column>
            <el-table-column
              prop="registCheckUserName"
              label="请验人"
              width="180">
            </el-table-column>
            <el-table-column prop="status" header-align="center" align="center" label="状态" width="100">
              <template slot-scope="{row}">
                <el-tag :type="statusFilter(row.status,'type')" size="small">
                  {{ statusFilter(row.status,'name') }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column
              prop="checkId"
              label="编号"
              width="180">
            </el-table-column>
            <el-table-column
              prop="dispenseDate"
              label="分样时间"
              width="180">
            </el-table-column>
            <el-table-column
              prop="batchNum"
              label="批号">
            </el-table-column>
            <el-table-column
              prop="productName"
              label="货品名">
            </el-table-column>
          </el-table>
<!--            <el-pagination
              layout="prev, pager, next"
              :total="checkToalPage">
            </el-pagination> -->


			<span slot="footer" class="dialog-footer">
				<el-button @click="closeSync">取 消</el-button>
				<el-button type="primary" class="pan-btn primary-btn" :loading="submitingSync" @click="submitSync">确 定
				</el-button>
			</span>
		</el-dialog>

		<add-or-update-module v-if="addModuleVisible" @close="close('addModuleVisible')" @refreshData="getDataList"
			:childDataForm="childDataForm" />

		<standard-collocate ref="showCollocate" v-if="collocateVisible" @close="close('collocateVisible')" />

		<standard-sort v-if="sortVisible" @close="close('sortVisible')" @refreshData="getDataList"
			:childDataForm="childDataForm" />

		<standard-report-preview v-if="reportVisible" @close="close('reportVisible')" :childDataForm="childDataForm" />

	</div>
</template>

<script>
	import CommonMethod from '@/views/mixin/common'
	import {
		getStandardList,
		deleteStandard,
		syncStandard,
		nowTakeEffect,
    syncStandard4Ids
	} from '@/api/standard'

  import {
    queryList4standUpdate
  } from '@/api/check'

	import {
		getSpecialConclusionItemsByStandardId
	} from '@/api/item'
	import {
		filterItems
	} from '@/api/report'
	import {
		getProductList
	} from '@/api/product'
	import {
		CODE_OK
	} from '@/common/js/config'
	import {
		parseTime,
		isBlank,
		getUUID,
		unique
	} from '@/common/js/utils'
	import AddOrUpdateModule from './standard-addorupdatemodule'
	import StandardCollocate from './standard-collocate'
	import StandardSort from './standard-sort'
	import StandardReportPreview from './standard-report-preview'
	export default {
		name: 'biaozhun',
		props: {
			isNoSelect: {
				type: Boolean,
				default: true
			},
			grandDataForm: {}
		},
		mixins: [CommonMethod],
		components: {
			AddOrUpdateModule,
			StandardCollocate,
			StandardSort,
			StandardReportPreview
		},
		data() {
			return {
        ids:"",
        tableData:[],
				dataList: [],
				dataListLoading: false,
				pageIndex: 1,
				pageSize: 10,
				totalPage: 0,
        checkPageIndex:1,
        checkPageSize:100000,
        checkToalPage:0,
        checkListLoading:false,
				dataForm: {
					accordingToInside: '',
					productGmpLike: '',
					insideInspectionStandardNum: '',
					nationInspectionStandardNum: ''
				},
				selectionList: [],
				addModuleVisible: false,
				childDataForm: "",
				collocateVisible: false,
				sortVisible: false,
				syncVisible: false,
				syncContent: '',
				startTime: '',
				reportVisible: false,
				syncWay: '',
				submitingSync: false
			}
		},
		created() {
			if (!isBlank(this.grandDataForm)) {
				this.dataForm.accordingToInside = this.grandDataForm.accordingToInside
			}
		},
		mounted() {
			this.getDataList()
		},
		methods: {
      statusFilter(status, val) {
        const statusMap = {
          0: {
            name: '待处理',
            type: 'danger'
          },
          1: {
            name: '待取样',
            type: 'primary'
          },
          2: {
            name: '待收样',
            type: 'warning'
          },
          3: {
            name: '待分发',
            type: 'warning'
          },
          4: {
            name: '检验中',
            type: 'warning'
          },
          5: {
            name: '检验中',
            type: 'warning'
          },
          6: {
            name: '待结论',
            type: 'warning'
          },
          10: {
            name: '待放行',
            type: 'success'
          },
          7: {
            name: '待放行',
            type: 'success'
          },
          8: {
            name: '待确认',
            type: 'success'
          },
          11: {
            name: '已完成',
            type: 'success'
          }
        }
        return statusMap[status][val]
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
        let tmpIds = [];
        for(let i = 0;i<val.length;i++){
          tmpIds.push(val[i].checkId);
        }
        this.ids = tmpIds.toString();
      },
      queryCheckList(){
        if(this.startTime == ""){
          this.$message.error("请选择分样起始日期")
          return
        }

        this.checkListLoading = true;
        //获得具体时间，具体货品的请验单列表
        const params = {
          page: this.checkPageIndex,
          limit: this.checkPageSize,
          status: '1,2,3,4,5,6,7,8,10',
          startTime: this.startTime,
          endTime: this.startTime,
          insideInspectionStandardId:this.childDataForm.insideInspectionStandardId
        }
        queryList4standUpdate(params).then(res => {
        	if (res.code === CODE_OK) {
        		this.tableData = res.page.list;
        		this.checkToalPage = res.page.totalCount;
        	}else{
        		this.$message.error(res.msg)
        	}
        	this.checkListLoading = false
        }).catch()
      },
			nowTake(row) {
				this.$confirm('确定 立即生效 吗,生效时间将设置为现在?', '提示', {
					confirmButtonText: '是的',
					cancelButtonText: '点错了',
					type: 'warning'
				}).then(() => {
					nowTakeEffect(row.insideInspectionStandardId).then(res => {
						if (res.code === CODE_OK) {
							this.getDataList()
						} else {
							this.$message.error(res.msg)
						}
					})
				}).catch(() => {})
			},
			rowClickHandle(row) {
				if (!this.isNoSelect) {
					this.$emit('clickRow', row)
				}
			},
			preview(row) {
				const params = {
					page: 1,
					limit: 1,
					standardId: row.isWaitTakeEffect == 0 ? row.parentId : row.insideInspectionStandardId
				}
				getProductList(params).then(res => {
					if (res.code === CODE_OK) {
						if (res.page.list.length != 0) {
							let product = res.page.list[0]
							//组装数据
							let standard = {
								accordingToInside: row.accordingToInside,
								accordingToNation: row.accordingToNation,
								insideVerdict: '本品按' + row.accordingToInside + '检验，结果符合规定。',
								nationVerdict: '本品按' + row.accordingToNation + '检验，结果符合规定。',
								specialValue: row.specialValue
							}
							if (!isBlank(row.specialValue)) {
								getSpecialConclusionItemsByStandardId(row.insideInspectionStandardId).then(res => {
									if (res.code === CODE_OK) {
										this.previewGoOn(row, product, standard, JSON.parse(JSON.stringify(
											row.items)), res.items)
									} else {
										this.$message.error(res.msg)
									}
								})
							} else {
								this.previewGoOn(row, product, standard, JSON.parse(JSON.stringify(row.items)),
									null)
							}
						} else {
							this.$message.error('请先绑定至少一个货品')
						}
					} else {
						this.$message.error(res.msg)
					}
				}).catch()
			},
			itemsPushSpecial(olds, news) {
				let arr = []
				// 分类数组
				let cs = unique(news.map(i => {
					return i.specialItemCategory
				}))
				for (let i = 0, j = cs.length; i < j; i++) {
					let ni = {
						printItemName: cs[i],
						isPrint: 0,
						printValue: null,
						printConfig: null
					}
					arr.push(ni)
					// 找出属于这个分类的
					for (let x = 0, y = news.length; x < y; x++) {
						if (!isBlank(news[x]) && news[x].specialItemCategory == cs[i]) {
							arr.push({
								isPrint: 0,
								printItemName: news[x].specialItemName,
								printValue: 0,
								nationInspectionItemValue: news[x].specialItemValue,
								insideInspectionItemValue: news[x].specialItemValue,
								printConfig: 0,
								itemConclusionMerge: news[x].specialItemConclusion
							})
							news[x] = null
						}
					}
				}
				olds.push(...arr)
				return olds
			},
			previewGoOn(row, product, standard, oldItems, newItems) {
				let checkList = {}
				let yfbList = {}
				let zcList = {}
				let ysList = {}
				let id = 1
				// let items = oldItems.filter(item => {
				// 	this.$set(item, 'checkItemId', id)
				// 	this.$set(item, 'itemConclusionMerge', '随机结果' + id++)
				// 	return item.isPrint == 0
				// })
        let items = [];
        for(let i = 0;i < oldItems.length;i++){
              let item = oldItems[i];
              item.checkItemId = id;
              item.isPrint = 0;
              item.itemConclusionMerge = '随机结果' + id++;
              items.push(item);
        }
				filterItems(items).then(res => {
					if (res.code === CODE_OK) {
						items = res.items
						if (!isBlank(newItems)) {
							items = this.itemsPushSpecial(items, newItems)
						}
						let now = new Date()
						let ymd = parseTime(now)
						if (product.productCategoryName == '原料' ||
							product.productCategoryName == '辅料' ||
							product.productCategoryName == '包材' ||
							product.productCategoryName == '其他') {
							checkList.checkNum = now.getFullYear() + '-' + product.productGmp + '-017'
							checkList.registCheckDepartmentName = '物流部'
							checkList.productPackSpec = '12350张/件'
							yfbList.originalBatch = '501/1911005'
							yfbList.grossQuantity = 198500
							yfbList.grossUnitName = '张'
							yfbList.supplierName = '成都倍特药业有限公司'
							yfbList.manufacturerName = '成都倍特药业有限公司'
							yfbList.validityDate = ymd
						} else if (product.productCategoryName == '中间品' || product.productCategoryName == '成品') {
							checkList.checkNum = product.productCategoryName == '中间品' ? (now.getFullYear() + '-' +
									product.productGmp + '-190666') :
								(now.getFullYear() + '-' + product.productGmp + '-017')
							checkList.productPackSpec = '12袋/盒'
							checkList.getQuantity = 66
							checkList.getUnitName = 'g'
							zcList.workshopName = '头孢口服固体制剂车间'
							zcList.procedureName = '总混'
							zcList.batchQuantity = 520
							zcList.batchUnitName = '万片'
							zcList.productionQuantity = 246810
							zcList.productionUnitName = '盒'
							zcList.productionDate = ymd
							zcList.validityDate = ymd
						} else if (product.productCategoryName == '制药用水/纯蒸汽') {
							checkList.checkNum = now.getFullYear() + '-' + product.productGmp + '-A-016'
							ysList.workshopName = '头孢口服固体制剂车间'
							ysList.getNames = product.productGmp + '-01、' + product.productGmp + '-02'
						}
						checkList.checkTypeId = product.productCategoryId
						checkList.checkTypeName = product.productCategoryName
						checkList.registCheckDate = ymd
						checkList.inspectDate = ymd
						checkList.reportDate = ymd
						checkList.productName = product.productName
						checkList.productGmp = product.productGmp
						checkList.productSpec = product.productSpec
						checkList.batchNum = '190666'
						this.childDataForm = {
							checkList: checkList,
							yfbList: yfbList,
							zcList: zcList,
							ysList: ysList,
							standard: standard,
							items: items
						}
						this.reportVisible = true
					} else {
						this.$message.error(res.msg)
					}
				})
			},
			sync(row) {
				this.$confirm('同步内容', '提示', {
					confirmButtonText: '成品及其他报告书',
					cancelButtonText: '稳考报告书',
					type: 'warning'
				}).then(() => {
					this.syncContent = 'cp'
					this.childDataForm = row
					this.syncVisible = !this.syncVisible
				}).catch(() => {
					this.syncContent = 'wk'
					this.childDataForm = row
					this.syncVisible = !this.syncVisible
				})
			},
			closeSync() {
				this.syncVisible = !this.syncVisible
			},
			submitSync() {
				if (isBlank(this.syncContent)) {
					this.$message("同步内容不全，请稍后再试")
					return
				}
				if (isBlank(this.startTime)) {
					this.$message("请选择一个时间点")
					return
				}
				if (this.syncContent != 'wk' && isBlank(this.syncWay)) {
					this.$message("请选择同步方式")
					return
				}
				if (this.syncWay == 1 && isBlank(this.childDataForm.parentId)) {
					this.$message("此标准没有对应的老标准，原因是没有通过系统提供的升级功能来升级标准，请联系管理员")
					return
				}
				this.submitingSync = true
				const data = {
					syncContent: this.syncContent,
					insideInspectionStandardId: this.childDataForm.insideInspectionStandardId,
					parentId: this.childDataForm.parentId,
					startTime: this.startTime,
					syncWay: this.syncWay,
          ids:this.ids
				}
				syncStandard4Ids(data).then(res => {
					if (res.code === CODE_OK) {
						this.$message({
							message: '同步成功',
							type: 'success',
							duration: 3500
						})
						this.closeSync()
					} else {
						this.$message.error(res.msg)
					}
					this.submitingSync = false
				})
			},
			goParent(num) {
				this.dataForm.insideInspectionStandardNum = num
				this.searchData()
			},
			sort(row) {
				this.childDataForm = row
				this.sortVisible = !this.sortVisible
			},
			upgrade(row) {
				this.childDataForm = {
					oldNum: '',
					oldId: '',
					dataForm: ''
				}
				let oldInsideNum = row.insideInspectionStandardNum
				this.childDataForm.oldNum = oldInsideNum
				this.childDataForm.oldId = row.insideInspectionStandardId
				let oldNumPre = oldInsideNum.substring(0, oldInsideNum.length - 2)
				let oldNumSuf = oldInsideNum.substring(oldInsideNum.length - 2)
				let newNumSuf = parseInt(oldNumSuf) + 1
				if (newNumSuf < 10) {
					newNumSuf = '0' + newNumSuf
				}
				let newNum = oldNumPre + newNumSuf
				this.childDataForm.dataForm = JSON.parse(JSON.stringify(row))
				this.childDataForm.dataForm.parentId = row.insideInspectionStandardId
				this.childDataForm.dataForm.parentNum = oldInsideNum
				this.childDataForm.dataForm.insideInspectionStandardNum = newNum
				let oldAccording = this.childDataForm.dataForm.accordingToInside
				let newAccording = oldAccording.replace(oldInsideNum, newNum)
				this.childDataForm.dataForm.accordingToInside = newAccording
				this.addModuleVisible = true
			},
			deleteData(id) {
				if (this.selectionList.length == 0 && id == undefined) {
					this.$message.error('请选择至少一个标准')
					return
				}
				let ids = id ? [id] : this.selectionList.map(item => {
					return item.insideInspectionStandardId
				})
				let msg = id ? '此操作将永久删除此标准, 是否继续?' : '此操作将永久删除选中的标准, 是否继续?'
				this.$confirm(msg, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					deleteStandard(ids).then(res => {
						if (res.code === CODE_OK) {
							this.$message({
								type: 'success',
								message: '删除成功!'
							})
							this.getDataList()
						} else {
							this.$message.error(res.msg)
						}
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					})
				})
			},
			collocate(row) {
				this.collocateVisible = true
				this.$nextTick(() => {
					this.$refs.showCollocate.init(row)
				})
			},
			updateData(row) {
				this.childDataForm = JSON.parse(JSON.stringify(row))
				this.addModuleVisible = !this.addModuleVisible
			},
			addModule() {
				this.childDataForm = ""
				this.addModuleVisible = !this.addModuleVisible
			},
			close(val) {
				this.childDataForm = ''
				this[val] = !this[val]
			},
			searchData() {
				this.pageIndex = 1
				this.getDataList()
			},
			getDataList() {
				this.dataListLoading = true
				const params = {
					page: this.pageIndex,
					limit: this.pageSize,
					accordingToInside: this.dataForm.accordingToInside || null,
					insideInspectionStandardNum: this.dataForm.insideInspectionStandardNum || null,
					nationInspectionStandardNum: this.dataForm.nationInspectionStandardNum || null
				}
				getStandardList(params).then(res => {
					if (res.code === CODE_OK) {
						this.dataList = res.page.list
						this.totalPage = res.page.totalCount
					} else {
						this.$message.error(res.msg)
					}
					this.dataListLoading = false
				}).catch()
			},
			selectionChange(obj) {
				this.selectionList = obj
			}
		}
	}
</script>

<style scoped>
	>>>.el-form-item__content {
		line-height: normal;
	}
</style>
